package com.example.leetdemo.finash;

public class Solution1518 {
    public int numWaterBottles(int numBottles, int numExchange) {
        int count = 0;
        int all = numBottles;
        while (true) {
            count += (all / numExchange) * numExchange;
            all = all % numExchange + all / numExchange;
            if (all < numExchange) {
                count += all;
                break;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Solution1518 solution1518 = new Solution1518();
        System.err.println(solution1518.numWaterBottles(9, 3));
    }
}
